'use strict'

class user{
    constructor(){

    }
    // 检验用户传入的验证码是否正确
    async post(c){
        let body=JSON.parse(c.body.toString());
        console.log(body);
        let imgarr=c.service.imgArr;
        let flag=false;
        for(let i=0;i<imgarr.length;i++){
            // imgarr里面的answer   body里面的val是用户输入的值
            if(imgarr[i].id==body.id && imgarr[i].answer==body.val){
                // console.log(imgarr[i].answer==body.val)
                flag=true;
            }
        }
        if(flag==true){
            c.send('验证成功');
            console.log('successful');
        }else{
            c.send('验证失败');
            console.log('fail');
        }
    }
}
module.exports=user;